include make.mk

ifeq ($(cube), 1)
CFLAGS +=  -DCUBE_COUNT_MODE
CXXFLAGS +=  -DCUBE_COUNT_MODE
NVCCFLAGS +=  -DCUBE_COUNT_MODE
LDFLAGS += -DCUBE_COUNT_MODE
endif

ifeq ($(cube), 2)
CFLAGS +=  -DCUBE_TIME_MODE
CXXFLAGS +=  -DCUBE_TIME_MODE
NVCCFLAGS +=  -DCUBE_TIME_MODE
LDFLAGS += -DCUBE_TIME_MODE
endif

FXGPU = fxgpu
FXGPU_OBJS = correlator.o cube.o

# header files
FXGPU_HDRS = cube.h

HDRS = $(FXGPU_HDRS)

all: $(FXGPU)

$(FXGPU): $(FXGPU_OBJS)
	$(CXX) $(LDFLAGS) $^ -o $@

$(FXGPU)_count: $(FXGPU_OBJS)
	$(CXX) $(LDFLAGS) -DCUBE_COUNT_MODE $^ -o $@

$(FXGPU)_time: $(FXGPU_OBJS)
	$(CXX) $(LDFLAGS) -DCUBE_TIME_MODE $^ -o $@

clean:
	-rm -f *.o $(FXGPU) $(FXGPU)_count $(FXGPU)_time

veryclean: clean
	-rm -f *log *.csv

%.o: %.c $(HDRS)
	$(CC) $(CFLAGS) $< -c -o $@

%.o: %.cpp $(HDRS)
	$(CXX) $(CXXFLAGS) $< -c -o $@

%.o: %.cu $(HDRS)
	$(NVCC) $(NVCCFLAGS) $< -c -o $@

.PHONY: all gen clean

#count: 	clean $(FXGPU)_count
#	./$(FXGPU)_count

#time: 	clean $(FXGPU)_time
#	./$(FXGPU)_time
